﻿<UserControl x:Class="MyImdb.Views.AllItemsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
             xmlns:converters="clr-namespace:MyImdb.Converters"
             mc:Ignorable="d"
             d:DesignHeight="600"
             d:DesignWidth="800">

    <UserControl.Resources>
        <converters:LocalPosterUrlConverter x:Key="PosterUrl" />
    </UserControl.Resources>

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <ScrollViewer>
            <StackPanel>
                <GroupBox Header="Items Count">
                    <TextBlock Text="{Binding ItemsCount}"
                               FontSize="32"
                               HorizontalAlignment="Center" />
                </GroupBox>

                <GroupBox Header="All">
                    <RadioButton Content="All"
                                 GroupName="filterTitle"
                                 IsChecked="{Binding IsAll, Mode=TwoWay}" />
                </GroupBox>

                <GroupBox Header="Movies">
                    <RadioButton Content="Movies"
                                 GroupName="filterTitle"
                                 IsChecked="{Binding IsMovies, Mode=TwoWay}" />
                </GroupBox>

                <GroupBox Header="TV Series">
                    <RadioButton Content="TV Series"
                                 GroupName="filterTitle"
                                 IsChecked="{Binding IsTvSeries, Mode=TwoWay}" />
                </GroupBox>

                <GroupBox Header="Year">
                    <StackPanel>
                        <RadioButton Content="Year"
                                     GroupName="filterTitle"
                                     IsChecked="{Binding IsYear, Mode=TwoWay}" />

                        <ListBox ItemsSource="{Binding Years}"
                                 IsEnabled="{Binding IsYear}"
                                 Height="150"
                                 SelectedItem="{Binding SelectedYear, Mode=TwoWay}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBlock Text="{Binding}"
                                                   FontSize="14"
                                                   Width="32"
                                                   Height="32"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>

                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Horizontal"
                                               Width="150" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </StackPanel>
                </GroupBox>

                <GroupBox Header="Starts With">
                    <StackPanel>
                        <RadioButton Content="Starts With"
                                     GroupName="filterTitle"
                                     IsChecked="{Binding IsStartsWith, Mode=TwoWay}" />
                        <ListBox ItemsSource="{Binding StartsWiths}"
                                 IsEnabled="{Binding IsStartsWith}"
                                 Height="150"
                                 SelectedItem="{Binding SelectedStartsWith, Mode=TwoWay}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBlock Text="{Binding}"
                                                   FontSize="14"
                                                   Width="32"
                                                   Height="32"
                                                   HorizontalAlignment="Center"
                                                   VerticalAlignment="Center" />
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>

                            <ListBox.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <WrapPanel Orientation="Horizontal"
                                               Width="150" />
                                </ItemsPanelTemplate>
                            </ListBox.ItemsPanel>
                        </ListBox>
                    </StackPanel>
                </GroupBox>

                <GroupBox Header="Actor">
                    <StackPanel>
                        <RadioButton Content="Actor"
                                     GroupName="filterTitle"
                                     IsChecked="{Binding IsActor, Mode=TwoWay}" />
                        <ListBox ItemsSource="{Binding Actors}"
                                 IsEnabled="{Binding IsActor}"
                                 Height="150"
                                 SelectedItem="{Binding SelectedActor, Mode=TwoWay}">
                            <ListBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid>
                                        <TextBlock Text="{Binding}"
                                                   FontSize="14"
                                                   HorizontalAlignment="Left"
                                                   VerticalAlignment="Stretch" />
                                    </Grid>
                                </DataTemplate>
                            </ListBox.ItemTemplate>
                        </ListBox>
                    </StackPanel>
                </GroupBox>

            </StackPanel>
        </ScrollViewer>

        <ListBox Margin="0"
                 Grid.Column="1"
                 x:Name="SearchList"
                 ItemsSource="{Binding FilteredItems}">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="10">
                        <GroupBox Header="{Binding Title}">
                            <Image Width="200"
                                   Height="300"
                                   Source="{Binding Poster, Converter={StaticResource PosterUrl}}" />
                        </GroupBox>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>

            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel Orientation="Horizontal"
                               Width="1000" />
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
        </ListBox>
    </Grid>
</UserControl>
